{% extends 'layout.html' %}
<!--
继承+重写
-->
{%block main%}
<div class="blog-container">
    <div class="">添加分类页面</div>
    <div>当前用户：{{userinfo.username}}（{{userinfo._id}}）</div>
    <h3>添加分类</h3>
    <div class="box">
        <div>
            <input type="text" id="name" name="name" placeholder="请输入分类名称">
        </div>
        <button type="submit" name="submit" id="tj">提交</button>
    </div>
</div>
<script>
    // bodyparser插件解析模式有问题，暂时只能用axios去提交请求
    $(document).on('click','#tj',function () {
        const name = document.getElementById('name').value;
        const dd = {
            name: name
        };
        axios({
            method: 'post',
            url: '/admin/category/add',
            data: dd
        }).then(function (response) {
            alert(response.data.name);
            window.location.href='http://localhost:8080/'+response.data.url;

        });
    });
</script>
{%endblock%}
